package com.punai.customer.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.customer.domain.CusMechanicalStaChapter;
import com.punai.customer.service.ICusMechanicalStaChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 机械章节Controller
 * 
 * @author zxw_
 * @date 2023-02-02
 */
@RestController
@RequestMapping("/cus/cusMechanicalStaChapter")
public class CusMechanicalStaChapterController extends BaseController
{
    @Autowired
    private ICusMechanicalStaChapterService cusMechanicalStaChapterService;

    /**
     * 查询机械章节列表
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaChapter:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusMechanicalStaChapter cusMechanicalStaChapter)
    {
        startPage();
        List<CusMechanicalStaChapter> list = cusMechanicalStaChapterService.selectCusMechanicalStaChapterList(cusMechanicalStaChapter);
        return getDataTable(list);
    }

    /**
     * 获取机械章节详细信息
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaChapter:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(cusMechanicalStaChapterService.selectCusMechanicalStaChapterById(id));
    }

    /**
     * 新增机械章节
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaChapter:add')")
    @Log(title = "机械章节", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusMechanicalStaChapter cusMechanicalStaChapter)
    {
        return toAjax(cusMechanicalStaChapterService.insertCusMechanicalStaChapter(cusMechanicalStaChapter));
    }

    /**
     * 修改机械章节
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaChapter:edit')")
    @Log(title = "机械章节", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusMechanicalStaChapter cusMechanicalStaChapter)
    {
        return toAjax(cusMechanicalStaChapterService.updateCusMechanicalStaChapter(cusMechanicalStaChapter));
    }

    /**
     * 删除机械章节
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaChapter:remove')")
    @Log(title = "机械章节", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(cusMechanicalStaChapterService.deleteCusMechanicalStaChapterByIds(ids));
    }
}
